package com.example.otto.mapper;

import com.example.otto.entity.Manager;
import com.example.otto.entity.Worker;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface WorkerMapper {

    @Select("select * from worker")
    List<Worker> findAll();

    @Select("select * from worker where state = 1")
    List<Worker> findBusy();

    @Select("select * from worker where state = 0")
    List<Worker> findFree();

    @Update("update worker set state = 1 where id = #{id}")
    boolean setBusy(String id);

    @Update("update worker set state = 0 where id = #{id}")
    boolean setFree(String id);

    //登录
    @Select("select * from worker where username = #{username} and password = #{password}")
    Worker login(Worker worker);

    @Select("select state from worker where id = #{id}")
    Integer getState(Integer id);
}
